﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using LogisticsBLL;

namespace WebLosgic.Carress
{
    public partial class Carriesdetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int CarrierID = Convert.ToInt32(Request.QueryString["ID"]);
                if (CarrierID != 0)
                {
                   
                    getBind(CarrierID);
                    GoodsBind(CarrierID);
                }
                else
                {
                    Response.Redirect("CarrierManage.aspx");
                }

            }
            
        }

        public void getBind(int carsID)
        {
            
            CarriessCyBLL cyb = new CarriessCyBLL();
            Carriers cars = cyb.Carrideail(carsID);
            labSendAddress.Text = cars.SendAddress;
            LabFK_ReceiveAddress.Text = cars.ReceiveAddress;
            LabReceiveCompany.Text = cars.ReceiveCompany;
            LabUserName.Text = cars.UserName;
            LabSendCompany.Text = cars.SendCompany;
            LabReceivePhone.Text = cars.ReceivePhone;
            LabLeaverDate.Text = cars.LeaverDate;
            LabReceiveDate.Text = cars.ReceiveDate;
            LabSendPhone.Text = cars.SendPhone;
            LabSendLinkman.Text = cars.SendLinkman;
            LabTotalCost.Text = cars.TotalCost;
            LabOtherCost.Text = cars.OtherCost;
            LabTransportCost.Text = cars.TransportCost;
            LabInsuranceCost.Text = cars.InsuranceCost;
            TxtRemark.Text = cars.Remark;
            int State = cars.FinishedState;
            LabLeaverDates.Text = cars.LeaverDate;
            LabFinishedState.Text = bindState(State);
        }

        public void GoodsBind(int carrsid)
        {
            CarriessCyBLL cb = new CarriessCyBLL();
            rptHuowu.DataSource = cb.Bindgoods(carrsid);
            rptHuowu.DataBind();
        }

        public string bindState(int state)
        {
            string str = "";
            switch (state)
            {
                case 0:
                    str = "待调度";
                    break;
                case 1:
                    str = "已调度";
                    break;
                case 2:
                    str = "已签收";
                    break;
                case 3:
                    str = "已结算";
                    break;
            }
            return str;
        }
    }
}